'use strict';

// 1. shell :  npx sequelize migration:generate --name=init-goods 生成该文件
// 2. shell :  npx sequelize db:migrate   执行 migrate 进行数据库变更
//
//
// # 如果有问题需要回滚，可以通过 `db:migrate:undo` 回退一个变更
// # npx sequelize db:migrate:undo
// # 可以通过 `db:migrate:undo:all` 回退到初始状态
// # npx sequelize db:migrate:undo:all
module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
         * Add altering commands here.
         *
         * Example:
         * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
         */
    const { INTEGER, DATE, STRING } = Sequelize;
    await queryInterface.createTable('goods', {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      title: STRING(30),
      desc: STRING,
      status: INTEGER,
      created_at: DATE,
      updated_at: DATE,
    });


  },

  down: async (queryInterface, Sequelize) => {
    /**
         * Add reverting commands here.
         *
         * Example:
         * await queryInterface.dropTable('users');
         */
    await queryInterface.dropTable('goods');
  },
};
